package accounting.controller.ajax;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.web.servlet.view.AbstractView;

import accounting.trade.model.vo.WarehouseVO;



public class JSonWarehouseView extends AbstractView{

	@Override
	protected void renderMergedOutputModel(Map map,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		ArrayList list=new ArrayList();
		Set set = map.keySet();
		Iterator itr = set.iterator();
		list=(ArrayList) map.get(itr.next());
		JSONArray array=new JSONArray();
		for(int i=0;i<list.size();i++){
			JSONObject obj=new JSONObject();
			WarehouseVO vo=(WarehouseVO) list.get(i);
			obj.put("warehouse_code",vo.getWarehouse_code());
			obj.put("warehouse_name", vo.getWarehouse_name());
			array.put(obj);
		}
		response.setContentType("text/html;charset=euc-kr");
		response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = response.getWriter();
		out.println(array.toString());
		out.close();
	}

}
